<?php
/**
 * 附件相关接口
 * @author maniac
 */
namespace app\api\controller\v1;

use app\facade\Attaches AS AttachesFacade;

class Attaches extends Base
{
    /**
     * 获取附件信息
     */
    public function attach()
    {
        $data     = input('post.');
        $md5_file = $data['md5_file'];
        $name     = $data['name'];
        $attach = AttachesFacade::attach($md5_file);
        if ($attach) {
            $attach['title'] = trim($name) ? $name : $attach['title'];
            $result['file']  = base64url_encode($attach['attach_uri'].'||'.$attach['title']);
            return j(0, '获取附件信息成功', $result);
        }
        return j(1, '附件不存在');
    }
}
